package com.davidx.tool.enums;


/**
 * The class Error code enum.
 *
 * @author Administrator
 */
public enum ErrorCodeEnum {
	//全局异常代码
	GL99990100(9999100, "参数异常"),
	GL99990401(99990401, "无访问权限"),
	GL99990500(500, "未知异常"),
	GL99990403(9999403, "无权访问"),
	GL99990404(9999404, "找不到指定资源"),
	GL99990001(99990001, "注解使用错误"),
	GL99990002(99990002, "网络链接超时"),
	GL99990003(99990003, "token无效"),
	GL99990004(99990004, "ip地址限制");


	private int code;
	private String msg;

	/**
	 * Msg string.
	 *
	 * @return the string
	 */
	public String msg() {
		return msg;
	}

	/**
	 * Code int.
	 *
	 * @return the int
	 */
	public int code() {
		return code;
	}

	ErrorCodeEnum(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	/**
	 * Gets enum.
	 *
	 * @param code the code
	 *
	 * @return the enum
	 */
	public static ErrorCodeEnum getEnum(int code) {
		for (ErrorCodeEnum ele : ErrorCodeEnum.values()) {
			if (ele.code() == code) {
				return ele;
			}
		}
		return null;
	}
}
